package com.guoqing.redis.controller;

import com.guoqing.redis.entity.Emp;
import com.guoqing.redis.service.EmpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther:
 * @Description:
 * @Date: 2019/12/23 16:07
 */
@RestController
@RequestMapping("/emp")
@Api(value = "controller", description = "Controller")
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping("/query")
    @ApiOperation(value = "查询全部", notes = "查询全部")
    public String empSelect() {
        List<Emp> list = empService.listAll();
        return list.toString();
    }

    @PostMapping("/del/{id}")
    @ApiOperation(value = "查询全部", notes = "查询全部")
    public String empDel(@PathVariable("id") String id) {
        empService.empDel(id);
        return "ok";
    }

    @GetMapping("/get/{id}")
    @ApiOperation(value = "查询全部", notes = "查询全部")
    public String getById(@PathVariable("id") String id) {
        Emp emp = empService.getEmpId(id);
        return emp.toString();
    }

    @PostMapping("/update/{id}")
    @ApiOperation(value = "查询全部", notes = "查询全部")
    public String empUpdate(@PathVariable("id") String id) {
        empService.empUpdate(id);
        return "ok";
    }
}
